/* Copyright(C): Leaf Johnson 2009,2010

    This file is part of leaf-lib.

    leaf-lib is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    leaf-lib is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with leaf-lib.  If not, see <http://www.gnu.org/licenses/>.


 * 
 * 
 */


#ifndef RADAR_H_INCLUDED
#define RADAR_H_INCLUDED
#include <leaf/base.h>
#include <leaf/checkbyte.h>
#define RADAR_NC  ((uint8_t)0xFA)
typedef uint8_t RadarPort;
typedef uint8_t RadarMsg[4];
static inline Bool  radar_validate( RadarMsg m )
{
	return PARSE_BOOL( calc_sum_byte( m, 3 ) == m[ 3 ] );
}
void  radar_write( RadarPort p, uint8_t b1, uint8_t b2, uint8_t b3 );
int   radar_recv( RadarPort p, void *buf, uint8_t header );
void  radar_set_timeout( unsigned int to );
int   radar_dist( RadarMsg msg );
int   radar_temperature( RadarMsg msg );
#ifdef _STDIO_H_
void  printRadarMsg( RadarMsg msg );
#endif

#endif
